package lab02.test21;

import java.util.*;
/**
 * 统计一个字符串中给定字符出现的频率
 */
public class Test {

        static String str="aqwertyuioplkjhgfdsazxvnmhdrgsbawanraq";

        static int amount(String s, char c) {

            int count = 0;

            for (int i = 0; i < s.length(); i++) {

                if (s.charAt(i) == c) {

                    count++;
                }
            }
            return count;
        }

        public static void main(String args[]) {

            System.out.println("输入的字符串："+str);

            System.out.println("字母a出现的频率："+amount(str, 'a'));
        }
    }

